﻿-- =============================================
-- Author:		<赵洪涛>
-- Create date: <2012-01-20>
-- Description:	<取销售人员的已成单记录>
-- =============================================
CREATE PROCEDURE [dbo].[proc_Order_MyOrder] 
	@UserName nvarchar(50),
	@StartIndex int,
	@EndIndex int,
@NOE_Flag int
AS
BEGIN
	;WITH list As (Select ROW_NUMBER() OVER (Order By TradeDate DESC) AS Row,
	Id,
	OId,
	CusId,
	CusName,
	CusPerson,
	CusPersonTel,
	TradeDate,
	IsNull(YingShouPrice,0) As YingShouPrice,
	IsNull(ShiShouPrice,0) As ShiShouPrice,
	StateId,
	IsNull(FinanceRenlingDate,'1900-01-01 0:00:00') As FinanceRenlingDate
	--IsNULL((select Pizhu from Customer_PiZhu where CustomerId=CusId),'''') as Pizhu, --批注内容字段 2015.08.20 
 --   IsNULL((select CusState from Customer_PiZhu where CustomerId=CusId),0) as CusState --是否有批注字段,
	From [Order]
    Where SalesmanAccount=@UserName And NOE_Flag=@NOE_Flag)

	Select *,(Select Count(0) From list) As RecordCount From list Where Row Between @StartIndex and @EndIndex
END
